(function(mui, document) {
	mui.init();

	mui.plusReady(function() {
		var userinfo = app.getState();
		var uid = userinfo.user_id;
		mui("#mywalletlist").on("tap", "a", function() {
			if(this.getAttribute("id") == "paymoney") {
				var w = document.getElementById('walletlistdetail');
				if(w == null || w == undefined) {
					mui.alert("请先创建钱包");
					return;
				}
			}

			var targets = this.getAttribute("href") + "?" + this.getAttribute("value");
			console.log(targets);
			mui.openWindow({
				url: targets,
				id: this.getAttribute("href")
			});
		});
		
		mui("#topPopover").on("tap", "a", function() {
			mui('#topPopover').popover('hide');

			if(this.getAttribute("id") == "reload") {
				location.reload();
				return true;
			}

			var targets = this.getAttribute("href");
			mui.openWindow({
				url: targets,
				id: targets
			});
		});

		document.getElementById("cashqrcode").addEventListener('tap', function() {
			var targets = 'cashqrcode.html';
			mui.openWindow({
				url: targets,
				id: targets
			});
		});
		document.getElementById("payqrcode").addEventListener('tap', function() {
			var targets = 'payqrcode.html';
			mui.openWindow({
				url: targets,
				id: targets
			});
		});
		document.getElementById("helps").addEventListener('tap', function() {
			var targets = '../../pages/system/wallet_help.html';
			mui.openWindow({
				url: targets,
				id: targets
			});
		});
	});

	window.addEventListener('refreshWnd', function(e) { //执行刷新
		location.reload();
	});
}(mui, document));

function copyaddress(obj){
	var data = obj.getAttribute("data-clipboard-text");
	var objd = document.getElementById('wallet_address_input');
	var dist = objd.setAttribute("data-clipboard-text", data);
	objd.click();
}

window.onload = function(){
	var clipboard = new Clipboard('#wallet_address_input');
	clipboard.on('success', function(e) {
		console.log(e);
		mui.toast("已复制钱包地址");
	});
}
